Repository navigation
sink: optional verdict and result joins, pending hold, column bounds and a run summary - #11
Conversation
…and a run summary All new keys are optional; with none of them configured the rows are byte-for-byte unchanged. - correlation.verdictMetric + computed:failedVerdict (1 / 0 / -1) - correlation.joinMetrics: merge a result sample's metadata into its request row through the request-id index; unmatched results counted - hold: keep a pending request row until its result arrives or the hold expires, then apply onExpireMeta - column bounds: type uint with min/max, maxRunes, distinct-value budgets with an overflow value, when conditions, joinDefault - cardinality.exemptMetrics - summary: one-line k=v file written at stop (also when the final flush fails), never through a symlink - check rows dropped on overflow / requeue / undelivered are counted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude review — head
|
MohitSinghBS
left a comment
There was a problem hiding this comment.
Approved at e6b3c4db
Nothing here blocks merging: every new key is optional, and nothing sets them until the caller config ships. The first finding needs a fix before that config turns on joinMetrics.
Checked locally: gofmt and go vet are clean, the sink and config tests pass with -race, and sink coverage is 91.8%. With no new keys set, a plain column renders exactly as before.
Against the GraphQL implementation (#3788)
This is the config-driven version of what #3788 adds to plu-clickhouse (buffer.go / client.go) and k6-req-capturer.js. I compared each part:
#3788 (plu-clickhouse) |
This PR | Matches? |
|---|---|---|
http_req_failed → reqFailed (1 / 0 / -1) |
verdictMetric + computed:failedVerdict |
yes |
lts_gql_result merged into its row by ltsReqId |
joinMetrics + bytesIdMetaKey |
yes, except finding 1 |
hold on ltsGqlPending=1, gqlHold capped at stale-after, expiry → state 3 + unattributed |
hold + onExpireMeta, max capped at staleAfter |
yes |
| a late result carrying the pending marker is not counted twice | same | yes |
| state outside 1–3 → 3; code and code source only when state = 2 | uint 1–3 + joinDefault "3"; when state == "2" |
yes |
| 500 operation names / 200 runes; 100 codes / 80 runes; message-derived codes get their own budget | distinct + maxRunes, partitionBy code source with partitions ["2"] |
yes |
| op type / shape / batch size only when there is an operation; batch size only when shape = 2 | when on the operation (+ shape = 2) |
yes |
lts_gql_calls / lts_gql_result left out of the series budget, exact names only |
cardinality.exemptMetrics |
yes |
signal line requestNameLimitHit;assertionsDropped;graphqlCalls;graphqlUnattributed;graphqlSampleN |
summary; the key order gives the same line |
yes |
results from http.batch (no id) counted by value, 1 to 1e6 |
unjoined adds the sample value |
yes |
Findings
1. Medium: a result sample can overwrite its row's URL with another request's URL. This differs from #3788.
addJoin(buffer.go:358-376) merges every kept metadata key from the result sample into the row, andurlMetaKeyis always kept.addGraphqlResultin #3788 only sets state, code and code source.- The capturer does not clear
urlFullafter a sync request, and the result of anasyncRequestis emitted in.then. Take this script:p = http.asyncRequest(<graphql>). The capturer clearsurlFull, so this row has nourlFull.http.get(otherUrl)setsurlFulltootherUrl.await p. The result is emitted whileurlFullis stillotherUrl.
- The GraphQL row then reads
url = "POST <otherUrl>". I reproduced this with a throwaway test againstwithOpJoin: the row came out as"url":"POST https://other.example.com/health"with requestNamePOST https://api.example.com/graphql. - Suggested fix: limit what a join sample can set, for example a
correlation.joinMetaKeysallowlist (state, code, code source), or never takeurlMetaKeyfrom a join sample. A capturer-side workaround also works: clearurlFullaroundemitAsyncGraphqlResult.
2. Low: redirect hops share ltsReqId. #3788 behaves the same way.
- The id index keeps only the last hop, so with the hold set, the first hop of a redirected
asyncRequestwaits 30s and is written as state 3 (not checked), and counted unattributed. removeEntry(buffer.go:396-401) also deletes the id when it already points at a later hop.- Suggested fix: delete the index only when it still points at this entry, and release the earlier hop's hold when a later hop takes the id over. I confirmed both with a throwaway test.
3. Nit: the summary file's folder is never created. writeSummary opens the path with O_EXCL, but marker files go through writeFile, which runs MkdirAll first. In a folder nothing else creates, the summary is never written and only a log line says why.
4. Note: exempt metrics match by exact name. This is the same in #3788. A script that records its own lts_gql_result adds series the limit never counts.
For the caller config PR
- Overflow values must be exactly
~lts.otherOperationsand~lts.otherCodes, since the BE readers label those strings (config/constants.js). summary.pathneeds a per-process path, like<PLU_CLICKHOUSE_SIGNALS_FILE>_<K6_POD_INSTANCE_ID>, so the primary and the RTLI secondaries don't overwrite each other.- Set the GraphQL summary keys,
failedVerdictand the joins only ongraphql_reportingpods. SetgraphqlSampleNonly while the response check is on.
Adds optional sink features so a caller can join per-request results and verdicts into request rows, hold a row until its result arrives, bound string and numeric columns, and get a one-line run summary at stop. Every new key is optional: with none configured, rows are byte-for-byte what they were (covered by golden-row tests in
bounds_test.go).New config keys (documented in the README sink section)
correlation.verdictMetric+computed:failedVerdict(1 failed / 0 ok / -1 none or WebSocket row)correlation.joinMetrics: a result sample's metadata is merged into its request row through the request-id index; results with no row are counted asunjoinedhold: a request row marked pending waits for its result, or untilmax(never abovestaleAfter), thenonExpireMetaappliestype: "uint"withmin/max,maxRunes,distinct(per-process value budget with an overflow value, optional bounded partitions),when,joinDefaultcardinality.exemptMetricssummary: ak=v;…file written at stop, cleared at start, written even when the final flush fails, created withO_EXCL(never through a symlink)Tests: new
verdict_test.go,join_test.go,hold_test.go,bounds_test.go,summary_test.go, plus config-validation cases (every new section rejects unknown keys).Not run locally: no Go toolchain on the authoring machine, so this PR's CI (
gofmt,go vet,go test -race) is the first compile. Follow-up commits fix whatever it reports.The caller-side config that uses these keys ships separately and only after this is on
main, because the config parser rejects unknown keys.🤖 Generated with Claude Code